Imports System.Data.SqlClient

Public Class AgendaDia : Implements IBusquedaFiltrado
    Private id As Integer
    Private descrip As String
    Public Property IdDia() As Integer
        Get
            Return id
        End Get
        Set(ByVal value As Integer)
            id = value
        End Set
    End Property
    Public Property Desc() As String
        Get
            Return descrip
        End Get
        Set(ByVal value As String)
            descrip = value
        End Set
    End Property

    Public Sub New()
        id = 0
        descrip = ""
    End Sub

    Public Function Agregar(ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Agregar
        Return True
    End Function

    Public Function Buscar(ByVal id As Integer, ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Buscar
        Dim comando As SqlDataAdapter
        Dim rs As DataTableReader
        Dim dato As DataTable
        Dim sql As String
        Dim lResp As Boolean = False

        sql = String.Format("SELECT * FROM AGENDADIA WHERE iddia ={0} ", id)
        comando = New SqlDataAdapter(sql, con.ConexionBase)
        dato = New DataTable("agendadia")
        comando.Fill(dato)
        rs = dato.CreateDataReader()
        comando.Dispose()
        dato.Dispose()

        If rs.Read Then
            id = System.Convert.ToInt16(rs("iddia"))
            Me.descrip = rs("descrip").ToString
            lResp = True
        Else
            lResp = False
            MsgBox("El dia no existe")
        End If
        rs.Close()
        Return lResp
    End Function

    Public Function Eliminar(ByVal id As Integer, ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Eliminar
        Return True
    End Function

    Public Function Modificar(ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Modificar
        Return True
    End Function
End Class
